﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HelloMinasan.Domain;
using System.ComponentModel.DataAnnotations;
using HelloMinasan.Caching;
using HelloMinasan.Caching.CacheObjects;
using HelloMinasan.Business;
using System.Web.Mvc;

namespace HelloMinasan.Web.ViewModels
{
    public class MessageModel
    {
        public int Id {get;set;}       
        public string Subject { get; set; }      
        public string Body { get; set; }
        public DateTime CreatedTime { get; set; }

        public UserBasicInfoModel Sender { get; set; }
        public int SenderId { get; set; }
        public string SenderDisplayName { get; set; }
        public bool SenderHasAvatar { get; set; }
        public UserType SenderUserType { get; set; }
        public string SenderFullName { get; set; }

        public UserBasicInfoModel Receiver { get; set; }
        public int ReceiverId { get; set; }
        public string ReceiverDisplayName { get; set; }
        public string ReceiverAvatarUrl { get; set; }
        public bool ReceiverHasAvatar { get; set; }
        public string ReceiverFullName { get; set; }

        public bool IsSystemMessage { get; set; }
        public MessageSystemFolder MessageSystemFolder { get; set; }
        //public UserType Source { get; set; }

        //public MessageListType Type { get; set; }


        //public int MyPartnerId { get; set; }


        //public Message Message { get; set; }

        public static MessageModel Create(Message message)
        {
            return new MessageModel
            {
                Id = message.Id,
                Subject = message.Subject,
                Body = message.Body,
                CreatedTime = message.CreatedTime,
                IsSystemMessage = message.IsSystemMessage,
                MessageSystemFolder = message.MessageSystemFolder,
                Sender = UserBasicInfoModel.Create(message.Sender.Id),
                Receiver = UserBasicInfoModel.Create(message.Receiver.Id)
            };
        }
    }
    
}